package kr.hkit.powerjava.chapter08;

class Student {
	private int stdNum; //학번
	private String stdName; //이름
	public int getStdNum() {
		return stdNum;
	}
	public void setStdNum(int stdNum) {
		if(stdNum > 0) {
			this.stdNum = stdNum;
		} else{
			this.stdNum = 1;
		}
		this.stdNum = stdNum;
	}
	public String getStdName() {
		return stdName;
	}
	public void setStdName(String stdName) {
		this.stdName = stdName;
	}
	@Override
	public String toString() {
		return stdNum + " : " + stdName;
	}
	
	public void getSum() {
		int sum = 0;
		int b = 2;
		for(int i = 0; i<101; i++){
//			int b = 2;  => 결과는 동일하지만 이럴경우 for문이 돌때마다 int b 가 선언되므로 비효율적. 
			sum += i + b;
		}
		System.out.println(sum);
		
	}
	
}

public class GetSetTest {
	public static void main(String[] args) {
		Student std = new Student();
		std.setStdNum(1);
		std.setStdName("김태희");
		
		Student std2 = new Student();
		std2.setStdNum(1);
		std2.setStdName("김태희");
		
/*		int i = 10;
		int j = 10;
		
		if(i ==j )
		{
			System.out.println("같음");
		}
		else{
			System.out.println("다름");
		}
		
		if(std == std2) {
			System.out.println("같음");
		}
		else {
			System.out.println("다름");
		}
		
		if(std.equals(std2)){
			System.out.println("같음");
		}
		else{
			System.out.println("다름");
		}*/
		
		Student std3 = std2;
		if(std3.equals(std2) ){
			System.out.println("같음");
		} else{
			System.out.println("다름");
		}
		
		
	}
}
